<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      Promise.resolve(config)
        .then((config) => {
          // 请求拦截器
          return config;
        })
        .then((config) => {
          return new Promise((resolve, reject) => {
            // 请求成功
            const response = {
              data: JSON.parse(xhr.responseText),
              status: xhr.statusCode,
            };

            resolve(response);

            //   请求失败
            reject(new Error("请求失败" + xhr.statusCode));
          });
        })
        .then(
          (response) => {
            // 响应拦截器
            return response.data;
          },
          (error) => {
            throw error;
          }
        )
        .then((result) => {})
        .catch((error) => {});
    </script>
  </body>
</html>
